use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct DownloadTask {
    pub category: String,
    pub pkgname: String,
    pub filename: String,
    pub icon: String,
    pub name: String,
    pub gid: String,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct InstallTask {
    pub category: String,
    pub pkgname: String,
    pub filepath: String,
    pub status: InstallStatus,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct DownloadTaskResponse {
    pub category: String,
    pub pkgname: String,
    pub filename: String,
    pub status: ResponseStatus,
    pub icon: String,
    pub name: String,
    pub progress: f32,
    pub speed: Option<String>,
    pub size: Option<String>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "lowercase")]
pub enum ResponseStatus {
    Downloading, // 下载中
    Queued,      // 等待下载
    Paused,      // 下载暂停
    Completed,   // 下载完成
    Error,       // 错误
    Installing,  // 安装中
    Installed,   // 安装完成
}

#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "lowercase")]
pub enum InstallStatus {
    Queued,     // 等待安装
    Error,      // 错误
    Installing, // 安装中
    Installed,  // 安装完成
}
